<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    <input name="name"><br/>
    <button type="button">上传</button>
</form>
<script src="/Public/js/jquery-1.11.1.min.js"></script>
<script src="/Public/js/jquery.validate.min.js"></script>
<script src="/Public/js/messages_zh.js"></script>
<script src="/Public/js/additional-methods.js"></script>
<script>
    var form=$('form');
    form.validate({
        rules:{
            name:{
                required:true,
                pattern:/^\d{3}$/
            }
        },
//        messages:
//        }
    });
    $('button').click(function(){
        if(!form.valid()){
            return;//没通过验证不提交
        }else {
            $.ajax({
                url:'<?php echo U("Yan/index");?>',
                data:form.serialize(),
                type:"post",
                dataType:"json",
                success:function (va){
                    console.log(va.mss);
                }
            })
        }
    })
</script>
</body>
</html>